package dfbz.homework1;

import java.util.ArrayList;

public class Test06 {
    public static void main(String[] args) {
        Teacher t1 = new Teacher("姚小明", 23, "打篮球");
        Teacher t2 = new Teacher("景甜", 20, "打羽毛球");
        Teacher t3 = new Teacher("薛之谦", 45, "踢足球");
        ArrayList<Teacher> list=new ArrayList<>();//传入自定义的Teacher对象 保存到集合list内
        list.add(t1);
        list.add(t2);
        list.add(t3);
//        int length1=list.size();
//        for (int i = 0; i < length1; i++) {
//            System.out.println(list.get(i).getName()+","+list.get(i).getAge()+","+list.get(i).getHobby());
//        }
//        System.out.println("-------------------------------------------------------------");
//        for (int i = 0; i < length1; i++) {
//            if(list.get(i).getAge()>40){
//                list.get(i).setHobby("高尔夫球");
////                System.out.println(list.get(i).getName()+","+list.get(i).getAge()+","+list.get(i).getHobby());
//                list.get(i).show();
//            }
//        }
        for (Teacher teacher:list){
            teacher.show();
            if(teacher.getAge()>40){
                teacher.setHobby("高尔夫球");
                teacher.show();
            }
        }
    }
}
